package cn.amebius.simpledocker.util;

import cn.amebius.simpledocker.exception.ParameterErrorException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 分页请求
 * @author 阿伟
 * @date 2023/8/2 15:04
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageRequest {

    private Integer pageSize;

    private Integer pageNum;

    private String keyWords;

    public void checkParameter() {
        if (keyWords == null) {
            keyWords = "";
        }
        if (pageNum < 0 || pageSize <= 0) {
            throw new ParameterErrorException("参数错误:分页参数格式错误");
        } else if (pageSize == null || pageNum == null) {
            throw new ParameterErrorException("参数错误:分页参数丢失");
        }
    }

}
